package com.yanyu.space.common.log.message;

import org.apache.commons.collections4.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 消息
 */
public class BatchLogMessage extends LogMessage{

    private List<LogMessage> batchMessages = new ArrayList<>();

    public void add(LogMessage logMessage) {
        batchMessages.add(logMessage);
        this.size += logMessage.size;
    }

    @Override
    public String toString() {
        StringBuffer sb = new StringBuffer();
        if (CollectionUtils.isNotEmpty(batchMessages)) {
            for (int i = 0; i < batchMessages.size(); i++) {
                sb.append(batchMessages.get(i).toString());
            }
        }
        return sb.toString();
    }
}
